//使用reduce方式来求数组中最大值的元素

const arr = [5, 12, 8, 3, 15, 7];

const maxElement = arr.reduce((max, current) => {
  return Math.max(max, current);
});

console.log(maxElement)
//使用reduce方式求出数组里元素之和

const arr1 = [5, 12, 8, 3, 15, 7];

const sum = arr1.reduce((total, current) => {
  return total + current;
}, 0);

console.log(sum);

